<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/24
 * Time: 14:56
 */

namespace app\lib\Exception;

use think\Exception;

class BaseException extends Exception
{
    public $message = '未知错误';
    public $code = '500';
    public $error_code = '10000';

    /**
     * 构造函数，接收一个关联数组
     * @param array $params 关联数组只应包含code、msg和errorCode，且不应该是空值
     */

    public function __construct(array $params = [])
    {
        if(!is_array($params))
        {
            return;
        }
        if(array_key_exists('message',$params))
        {
            $this->message = $params['message'];
        }
        if(array_key_exists('code',$params))
        {
            $this->code = $params['code'];
        }
        if(array_key_exists('error_code',$params))
        {
            $this->error_code = $params['error_code'];
        }
    }

}